﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assessment.Management.SharedComponent.Params.CommonParam;
using Assessment.Management.SharedComponent.Constants;
using Assessment.Management.SharedComponent.Entities;

namespace Assessment.Management.DAO.CommonManagers
{
    public class GroupQuestionDAO : BaseDaos
    {
        public GroupQuestionDAO()
            :base()
        {
        }

        public void GetListGroupQuestion(GroupQuestionParam param)
        {
            string query = "Select * from Groups where Deleted=@Deleted";

            var cmd = base.GetSqlCommand();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@Deleted", SMX.smx_IsNotDeleted);
            try
            {
                param.listGroupQuestion = base.ExecuteQueryGetListObject<GroupQuestion>(cmd);
            }
            finally
            {
                base.CloseConnection(cmd);
            }
        }

        public void GetGroupQuestionByID(GroupQuestionParam param)
        {
            string query = "Select * from Groups where Deleted=@Deleted and ID=@ID";

            var cmd = base.GetSqlCommand();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@Deleted", SMX.smx_IsNotDeleted);
            cmd.Parameters.AddWithValue("@ID", param.GroupQuestion.ID);
            try
            {
                param.GroupQuestion = base.ExecuteQueryGetObject<GroupQuestion>(cmd);
            }
            finally
            {
                base.CloseConnection(cmd);
            }
        }
    }
}
